Skip to content

fix(render): last() silently returns nil for []*entity.Entity slices#101

Merged
greynewell merged 1 commit intomainfrom
fix-last-entity-slice
Apr 9, 2026
Merged

fix(render): last() silently returns nil for []*entity.Entity slices#101
greynewell merged 1 commit intomainfrom
fix-last-entity-slice

Conversation

@greynewell
Copy link
Copy Markdown
Contributor

Summary

  • last() handled []string and []interface{} but was missing the []*entity.Entity case that first() already had
  • Any template calling {{ last .Entities }} on an entity list would silently receive nil and render nothing, with no error
  • Fix: add the []*entity.Entity case to last() to match first()

Test plan

  • TestFirstLast_EntitySlice covers first and last with non-empty and empty entity slices
  • go test ./internal/archdocs/pssg/render/... passes
  • go build ./... passes

🤖 Generated with Claude Code

last() handled []string and []interface{} but was missing the
[]*entity.Entity case that first() already had. Any template calling
{{ last .Entities }} on an entity list would receive nil and produce
a silent empty output instead of the last entity.

Also adds TestFirstLast_EntitySlice covering both functions with entity
slices, including empty-slice behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Warning

Rate limit exceeded

@greynewell has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b476f5cc-18fd-403f-8fc2-8047cce84e76

📥 Commits

Reviewing files that changed from the base of the PR and between ac01b6d and 58e4fbb.

📒 Files selected for processing (2)
  • internal/archdocs/pssg/render/funcs.go
  • internal/archdocs/pssg/render/funcs_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-last-entity-slice

Comment @coderabbitai help to get the list of available commands and usage tips.

@greynewell greynewell merged commit 7ab1310 into main Apr 9, 2026
7 checks passed
@greynewell greynewell deleted the fix-last-entity-slice branch April 9, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant